<?php
namespace app\wechat\controller;
use app\Service\Sms;
class Send{
    public function sendCode(){
        $sms = new Sms();
        $array = ['resetPassword','login','resetImportantPwd','bandMobile'];
        try{
            $params = input('param.');
            if(empty($params['username'])){
                throw new \LogicException('手机号不能为空',10010);
            }
            if(!in_array($params['action'],$array)){
                throw new \LogicException('action不在操作范围内',10011);
            }
            $sms->sendCode($params);
        }catch(\Exception $e){
            return Response::data($e->getCode(),$e->getMessage());
        }
        return Response::data(200,'success');
    }
}